<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:35:"./themes/admin/auth_group\auth.html";i:1741049647;s:39:"D:\phpcode\dpwkt\themes\admin\base.html";i:1741049647;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo $setup['title']; ?></title>
    <meta content="<?php echo $setup['keywords']; ?>" name="keywords" />
    <meta content="<?php echo $setup['description']; ?>" name="description" />
    <?php if($setup['ico'] != null): ?><link rel="shortcut icon" type="image/x-icon"  href="/public/uploads/<?php echo $setup['ico']; ?>"/><?php endif; ?>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
    <!--CSS引用-->
    
    <!--页面CSS-->
    <!--[if lt IE 9]>
    <script src="/public/static/js/html5shiv.min.js"></script>
    <script src="/public/static/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>

<!--tab标签-->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class=""><a href="<?php echo url('admin/auth_group/index'); ?>">权限组</a></li>
                <li class=""><a href="<?php echo url('admin/auth_group/add'); ?>">添加权限组</a></li>
                <li class="layui-this">编辑权限组</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form layui-form-pane" action="<?php echo url('admin/auth_group/updateAuthGroupRule'); ?>" method="post">
                        <?php if(is_array($auth_rule_list) || $auth_rule_list instanceof \think\Collection || $auth_rule_list instanceof \think\Paginator): if( count($auth_rule_list)==0 ) : echo "" ;else: foreach($auth_rule_list as $key=>$v): ?>
                        <fieldset class="layui-elem-field">
                            <legend><?php echo $v['title']; ?><input type="checkbox" lay-filter="checkbox_one"  value="<?php echo $v['id']; ?>" name="menu[]" id="menu_<?php echo $v['id']; ?>" title="<?php echo $v['title']; ?>" <?php if($v['checked']==1): ?>checked=""<?php endif; ?>></legend>
                            <?php if(is_array($v['two']) || $v['two'] instanceof \think\Collection || $v['two'] instanceof \think\Paginator): if( count($v['two'])==0 ) : echo "" ;else: foreach($v['two'] as $key=>$vv): ?>
                            <div class="layui-form-item" style="padding-left: 10px;">
                                <label class="layui-form-label"><?php echo $vv['title']; ?></label>
                                <div class="layui-input-block">
                                    <input type="checkbox" lay-filter="checkbox_two"  value="<?php echo $vv['id']; ?>" name="menu[]" id="menu_<?php echo $v['id']; ?>_<?php echo $vv['id']; ?>" title="<?php echo $vv['title']; ?>" <?php if($vv['checked']==1): ?>checked=""<?php endif; ?>>
                                    <?php if(is_array($vv['three']) || $vv['three'] instanceof \think\Collection || $vv['three'] instanceof \think\Paginator): if( count($vv['three'])==0 ) : echo "" ;else: foreach($vv['three'] as $key=>$vvv): if($vvv['four'] == null): ?>
                                    <input type="checkbox" lay-filter="checkbox_three"  value="<?php echo $vvv['id']; ?>" name="menu[]" id="menu_<?php echo $v['id']; ?>_<?php echo $vv['id']; ?>_<?php echo $vvv['id']; ?>" title="<?php echo $vvv['title']; ?>" <?php if($vvv['checked']==1): ?>checked=""<?php endif; ?>>
                                    <?php else: ?>
                                    <div class="layui-form-item" style="padding-top: 10px;margin-bottom:0px;">
                                        <label class="layui-form-label"><?php echo $vvv['title']; ?></label>
                                        <div class="layui-input-block">
                                            <input type="checkbox" lay-filter="checkbox_three"  value="<?php echo $vvv['id']; ?>" name="menu[]" id="menu_<?php echo $v['id']; ?>_<?php echo $vv['id']; ?>_<?php echo $vvv['id']; ?>" title="<?php echo $vvv['title']; ?>" <?php if($vvv['checked']==1): ?>checked=""<?php endif; ?>>
                                            <?php if(is_array($vvv['four']) || $vvv['four'] instanceof \think\Collection || $vvv['four'] instanceof \think\Paginator): if( count($vvv['four'])==0 ) : echo "" ;else: foreach($vvv['four'] as $key=>$vvvv): ?>
                                            <input type="checkbox" lay-filter="checkbox_four" value="<?php echo $vvvv['id']; ?>" name="menu[]" id="menu_<?php echo $v['id']; ?>_<?php echo $vv['id']; ?>_<?php echo $vvv['id']; ?>_<?php echo $vvvv['id']; ?>" title="<?php echo $vvvv['title']; ?>" <?php if($vvvv['checked']==1): ?>checked=""<?php endif; ?>>
                                            <?php endforeach; endif; else: echo "" ;endif; ?>
                                        </div>
                                    </div>
                                    <?php endif; endforeach; endif; else: echo "" ;endif; ?>
                                </div>
                            </div>
                            <?php endforeach; endif; else: echo "" ;endif; ?>
                        </fieldset>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                        <input type="hidden" id="group_id" name="group_id" value="<?php echo $id; ?>">
                        <button class="layui-btn" lay-submit lay-filter="*">授权</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!--页面-->

<!--JS引用-->
<script src="/public/static/js/jquery.min.js"></script>
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: "lib/index" //主入口模块
    }).use('index');
</script>

<script>
    layui.use(['form'], function(){
        var form = layui.form;

        /**
         * 通用表单提交(AJAX方式)
         */
        form.on('submit(*)', function (data) {
            $.ajax({
                url: data.form.action,
                type: data.form.method,
                data: $(data.form).serialize(),
                success: function (info) {
                    if (info.code === 1) {
                        setTimeout(function () {
                            location.href = info.url;
                        }, 1000);
                    }
                    layer.msg(info.msg);
                }
            });
            return false;
        });

        //全选按钮
        form.on('checkbox(checkbox_one)', function(data){
            var child = $("[id^="+$(data.elem).eq(0).attr('id')+"]");
            child.each(function(index, item){
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });
        form.on('checkbox(checkbox_two)', function(data){
            var child_check = $(data.elem).eq(0).attr('id').split('_');

            var one=$("#"+child_check[0]+"_"+child_check[1]);
            one.prop('checked',true);

            var child = $("[id^="+$(data.elem).eq(0).attr('id')+"_]");
            child.each(function(index, item){
                item.checked = data.elem.checked;
            });

            form.render('checkbox');
        });
        form.on('checkbox(checkbox_three)', function(data){
            var child_check = $(data.elem).eq(0).attr('id').split('_');

            var one=$("#"+child_check[0]+"_"+child_check[1]);
            one.prop('checked',true);

            var two=$("#"+child_check[0]+"_"+child_check[1]+"_"+child_check[2]);
            two.prop('checked',true);

            var child = $("[id^="+$(data.elem).eq(0).attr('id')+"_]");
            child.each(function(index, item){
                item.checked = data.elem.checked;
            });

            form.render('checkbox');
        });
        form.on('checkbox(checkbox_four)', function(data){
            var child_check = $(data.elem).eq(0).attr('id').split('_');

            var one=$("#"+child_check[0]+"_"+child_check[1]);
            one.prop('checked',true);

            var two=$("#"+child_check[0]+"_"+child_check[1]+"_"+child_check[2]);
            two.prop('checked',true);

            var three=$("#"+child_check[0]+"_"+child_check[1]+"_"+child_check[2]+"_"+child_check[3]);
            three.prop('checked',true);

            form.render('checkbox');
        });
    });
</script>

<!--页面JS脚本-->
</body>
</html>

